export class BaseMessage {
    constructor(id, no, createTime) {
        this.id = id
        this.no = no
        this.createTime = createTime
    }
}

// request message

export class Authentication extends BaseMessage {
    
    constructor(id, no, createTime, name, avatar) {
        super(id, no, createTime);
        this.name = name;
        this.avatar = avatar;
    }
}

export class HeartBeat extends BaseMessage {}

export class Send extends BaseMessage {
    
    constructor(id, no, createTime, to, content) {
        super(id, no, createTime);
        this.to = to;
        this.content = content;
    }
}

export class UserList extends BaseMessage {}

// response message

export class CommonResponse extends BaseMessage {

    constructor(id, no, createTime, responseNo, result) {
        super(id, no, createTime);
        this.responseNo = responseNo;
        this.result = result;
    }
}

export class AuthenticationResponse extends CommonResponse {

    constructor(id, no, createTime, name) {
        super(id, no, createTime);
        this.name = name;
    }
}

export class Receive extends BaseMessage {
    
    constructor(id, no, createTime, from, content) {
        super(id, no, createTime);
        this.from = from;
        this.content = content;
    }
}

export class UserListResponse extends CommonResponse {

    constructor(id, no, createTime, users) {
        super(id, no, createTime);
        this.users = users;
    }
}

export class User {

    constructor(id, status, name, avatar) {
        this.id = id;
        this.status = status;
        this.name = name;
        this.avatar = avatar;
    }
}


/**
 * 心跳
 */
export const HEART_BEAT = 0x0;
/**
 * 通用回复
 */
export const COMMON_RESPONSE = 0x100;
/**
 * 鉴权
 */
export const AUTHENTICATION = 0x1;
/**
 * 鉴权回复
 */
export const AUTHENTICATION_RESPONSE = 0x101;
/**
 * 获取联系人列表
 */
export const GET_USER_LIST = 0x2;
/**
 * 获取联系人列表回复
 */
export const GET_USER_LIST_RESPONSE = 0X102;
/**
 * 发送消息
 */
export const SEND_MESSAGE = 0x3;
/**
 * 接收消息
 */
export const RECEIVE_MESSAGE = 0x4;